<%@ page pageEncoding="UTF-8"%>
<%@ taglib prefix="isperp" uri="/WEB-INF/tlds/isperp.tld"%>
<script type="text/javascript">
	function incidentGridActions(rowObject) {
		return isperp.createGridAction({
			title : '催办',
			iconCls : 'icon-notify',
			onclick : "isperp.openDialog({title:'事件催办',windowSize:'normal',contentUrl:'app/message/sender/sendEdit?title=【催办】事件编号【" + rowObject.code + "】请速处理&sourceId=" + rowObject.id + "'})"
		});
	}

	function loadMessageCount(data) {
		if (data) {
			var ids = "";
			var d = data.content;
			if (d) {
				for ( var i = 0; i < d.length; i++) {
					ids += "," + d[i].id;
				}
				if (ids != "") {
					$.post("app/message/findCountsBySourceIds", {
						all : 1,
						ids : ids
					}, function(result) {

						$(result).each(function(index, item) {
							var l = $("#msg_" + item.source_id);
							l.addClass("msg-link");
							l.html(item.count_t);
						});

					});
				}
			}
		}

	}
</script>
<isperp:grid url="incident/incident/listMonitorSpecialDetail"
	actionsWidth="90" gridId="incidentGrid" sortorder="desc"
	ondbClickRowEvent="incidentGrid.view(rowid);"
	autoReloadTreeMenu="incidentMenu" cusViewUrl="incident/incident/view"
	loadComplete="loadMessageCount(data);"
	excelExportUrl="incident/incident/excelExport" 
	cusActions="incidentGridActions(rowObject);">

	<jsp:attribute name="toolbar">
	<isperp:treeMenu id="incidentMenu" targetGridId="incidentGrid">
		<isperp:async enable="true" url="incident/incident/monitorSpecialMenu"></isperp:async>
		<isperp:callback onClick="incidentMenuTree_onNodeClick"
				onAsyncSuccess="incidentMenuTree_onNodeClickFirst();">
		</isperp:callback>
	</isperp:treeMenu>
	<isperp:toolbar id="userToolbar">
	<%-- 	<isperp:button id="userEdit" icon="icon-download" text="导出到Excel"
				onclick="incidentGrid.excelExport();"></isperp:button> --%>
	</isperp:toolbar>
	</jsp:attribute>

	<jsp:attribute name="searchbar">
	<table class="search-table">
		<tbody>
			<tr>
				<td class="td1">编号：</td>
				<td class="td2"><input type="text" field="code" op="cn">
					</td>
				<td class="td1">标题：</td>
				<td class="td2"><input type="text" field="title" op="cn">
					</td>
				<td class="td1">事件分类：</td>
				<td class="td2"><input type="text" field="icd_category_name"
						op="cn">
				</td>
			</tr>
			<tr>
				<td class="td1">申报人：</td>
				<td class="td2"><input type="text" field="cus_user_name"
						op="cn">
					</td>
				<td class="td1">登记时间：</td>
				<td class="td2"><input id="createDateStart" type="date"
						field="create_date" op="gt" style="width: 68px" />~<input
						id="createDateEnd" type="date" field="create_date" op="lt"
						style="width: 68px" />
				</td> 
			 
				<td class="td1">性质：</td>
			  <td class="td2" colspan="5">
				<isperp:dictSelector typeCode="INCIDENT_NATURE"
							name="event_nature" id="event_nature" multiple="true"
							hasEmptyValue="true" field="incident_type" op="eq"></isperp:dictSelector>
			  </td>
			 
			</tr>
			
		</tbody>
	</table>
	</jsp:attribute>
	<jsp:body>
	<isperp:column name="id" title="" hidden="true"></isperp:column>
	<isperp:column name="sla_status" title="" hidden="true"></isperp:column>
	<isperp:column name="priority_name" title="" width="40"
			isFormatterFun="true" formatter="return statusFormatter(rowObject);">
	</isperp:column>
	<isperp:column name="code" title="编号" width="100">
	</isperp:column>
	<isperp:column name="title" title="标题" width="120">
	</isperp:column>
	<isperp:column name="icd_category_name" title="事件分类" width="120">
	</isperp:column>
		<isperp:column name="incident_type" title="性质" width="70">
	</isperp:column>
	<isperp:column name="cus_customer_name" title="申报单位" width="70">
	</isperp:column>
	<isperp:column name="cus_user_name" title="申报人" width="80">
	</isperp:column>
		<isperp:column name="confirmtimeman_name" title="IS担当" width="75">
	</isperp:column>
	<isperp:column name="solver_name" title="支持人员" width="75">
	</isperp:column>
	<isperp:column name="create_date" title="登记时间" width="100">
	</isperp:column>
	<isperp:column name="status" title="状态" width="80">
	</isperp:column>
	</jsp:body>
</isperp:grid>

<isperp:operate code="INC_HANDLE"></isperp:operate>

<script type="text/javascript">
	$(function() {
		$("[name='incident_type']").attr("checked", true)
	});
	function pageResetSearch() {
		$("#incidentGridAdSearchTb input[type!='radio']").each(function() {
			var $el = $(this);
			$el.val("");
		});
		$("#incidentGridAdSearchTb select").each(function() {
			var $el = $(this);
			$el.val("");
			$el.trigger("chosen:updated");

		});
	}
	function statusFormatter(rowObject) {
		var p = 0, html = "", title = "";
		if (rowObject.priority_name != null) {

			switch (rowObject.priority_name) {
			case "一级":
				p = 1;
				break;
			case "二级":
				p = 2;
				break;
			case "三级":
				p = 3;
				break;
			case "四级":
				p = 4;
				break;
			case "五级":
				p = 5;
				break;
			}
			title = "优先级：" + p + "级";
		} else {
			title = "未确定优先级";
		}

		html = "<img title='"+title+"' src='img/incident/p"+p+".png'>";
		if (rowObject.sla_status == 1) {

			html = html + "&nbsp;<img title='SLA：异常'  src='img/incident/sla_unusual.png'>";
		}
		return html + "&nbsp;<a id='msg_" + rowObject.id + "' href=\"javascript:openRelationMessage('" + rowObject.id + "')\" class=''></a>";
	}

	function openRelationMessage(id) {

		isperp.openDialog({
			title : "查看消息",
			contentUrl : "app/message/relationMessageView?all=1&sourceId=" + id
		});
	}
</script>